import * as echarts from 'echarts'
import { yAxis, xAxis, grid, nowSize } from '@/assets/js/echarts/config'

export default ({
    tagId, data = {},
}) => {
    const myChart = echarts.init(document.getElementById(tagId));
    myChart.clear()
    const option = {
        grid,
        tooltip: {
            trigger: 'axis',
        },
        xAxis: {
            type: 'category',
            data: data.x,
            ...xAxis,
            axisLabel: {
                show: true,
                color: '#999999',
                fontSize: 11,
                formatter: (val) => val.substr(-2),
            },

        },
        yAxis: {
            type: 'value',
            ...yAxis,

        },
        series: [{
            name: '当日办理量',
            data: data.chartdata,
            type: 'bar',
            barWidth: 4,
            itemStyle: {
                color: '#acabf6'
            },
            label: {
                show: true,
                position: 'top',
                fontSize: 10,
            },
        }]
    }
    myChart.setOption(option)
    // 图表自适应
    window.addEventListener('resize', function () {
        myChart.resize();
    })
}